package nachos.vm;
import java.util.Formatter;
import nachos.machine.TranslationEntry;

class TranslationUtils {

    /**
     * Return a multi-line string representing the given translation
     * entries. Useful for debugging a page table or TLB.
     */
    public static String formatTable(TranslationEntry... entries) {
	Formatter f = new Formatter()
	    .format("%n")
	    .format("%6s %6s %5s %5s %5s %5s%n",
		     "VPN", "PPN", "Valid", "R.O.", "Used", "Dirty");
	for (TranslationEntry e : entries) {
	    f.format("%6d %6d %5b %5b %5b %5b%n",
		     e.vpn, e.ppn, e.valid, e.readOnly, e.used, e.dirty);
			      
	}
	return f.toString();
    }
}